bitkeeper revision 1.1005 (40d99af0Cf4EQLv6pL5rlJVam_lZHg)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Wed, 23 Jun 2004 15:00:00 +0000 (15:00 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Wed, 23 Jun 2004 15:00:00 +0000 (15:00 +0000)
Remove some obsolete miscellaneous tools.

13 files changed:
.rootkeys
tools/Makefile
tools/balloon/Makefile [deleted file]
tools/balloon/README [deleted file]
tools/balloon/balloon.c [deleted file]
tools/misc/Makefile
tools/misc/xen-mkdevnodes [deleted file]
tools/misc/xen_dmesg.py [deleted file]
tools/misc/xen_log.c [deleted file]
tools/misc/xen_nat_enable [deleted file]
tools/misc/xen_nat_enable.README [deleted file]
tools/nsplitd/Makefile [deleted file]
tools/nsplitd/nsplitd.c [deleted file]

index acbd6201cb8d6b9e8c0bc88f3ecf8199269972b1..b1ecb1f17484d2cbf495997156e61cf057e5e315 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
 409ba2e7akOFqQUg6Qyg2s28xcXiMg linux-2.4.26-xen-sparse/mm/page_alloc.c
 3e5a4e683HKVU-sxtagrDasRB8eBVw linux-2.4.26-xen-sparse/mm/swapfile.c
 3f776bd1Hy9rn69ntXBhPReUFw9IEA tools/Makefile
-3e6377b24eQqYMsDi9XrFkIgTzZ47A tools/balloon/Makefile
-3e6377d6eiFjF1hHIS6JEIOFk62xSA tools/balloon/README
-3e6377dbGcgnisKw16DPCaND7oGO3Q tools/balloon/balloon.c
 401d7e160vaxMBAUSLSicuZ7AQjJ3w tools/examples/Makefile
 401d7e16UgeqroJQTIhwkrDVkoWgZQ tools/examples/README
 401d7e16GS8YesM1zateRbaOoI6YLQ tools/examples/defaults
 3f870808_8aFBAcZbWiWGdgrGQyIEw tools/misc/p4perf.h
 3f5ef5a2ir1kVAthS14Dc5QIRCEFWg tools/misc/xen-clone
 3f5ef5a2dTZP0nnsFoeq2jRf3mWDDg tools/misc/xen-clone.README
-3f1668d4-FUY6Enc7MB3GcwUtfJ5HA tools/misc/xen-mkdevnodes
 3f870808zS6T6iFhqYPGelroZlVfGQ tools/misc/xen_cpuperf.c
-401d7e16hWEsgEnMwbPM9sKyInomWw tools/misc/xen_dmesg.py
-3f8bcf29ulZIC9rC4wM70H_q4s6VPg tools/misc/xen_log.c
-3f13d81eQ9Vz-h-6RDGFkNR9CRP95g tools/misc/xen_nat_enable
-3f13d81e6Z6806ihYYUw8GVKNkYnuw tools/misc/xen_nat_enable.README
 405eedf6_nnNhFQ1I85lhCkLK6jFGA tools/misc/xencons
 4056f5155QYZdsk-1fLdjsZPFTnlhg tools/misc/xensymoops.py
-4022a73cEKvrYe_DVZW2JlAxobg9wg tools/nsplitd/Makefile
-4022a73cKms4Oq030x2JBzUB426lAQ tools/nsplitd/nsplitd.c
 3fbca441SjQr8vJwTQIgH1laysaWog tools/xc/Makefile
 3fbba6dbDfYvJSsw9500b4SZyUhxjQ tools/xc/lib/Makefile
 3fbba6dc1uU7U3IFeF6A-XEOYF2MkQ tools/xc/lib/rpm.spec
index 8e9c8e77fdddf41f49f9f1c395dee19d9f9ab3cf..658ff284d1ac480c34cd071af80e101f87e48af3 100644 (file)
@@ -1,6 +1,5 @@
 
 all:   
-       $(MAKE) -C balloon
        $(MAKE) -C xc
        $(MAKE) -C misc
        $(MAKE) -C examples
@@ -10,7 +9,6 @@ all:
        $(MAKE) -C xenmgr
 
 install: all
-       $(MAKE) -C balloon install
        $(MAKE) -C xc install
        $(MAKE) -C misc install
        $(MAKE) -C examples install
@@ -24,11 +22,9 @@ dist: $(TARGET)
 
 
 clean:
-       $(MAKE) -C balloon clean
        $(MAKE) -C xc clean
        $(MAKE) -C misc clean
        $(MAKE) -C examples clean
-       $(MAKE) -C nsplitd clean
        $(MAKE) -C xentrace clean
        $(MAKE) -C xenctl clean
        $(MAKE) -C xend clean
diff --git a/tools/balloon/Makefile b/tools/balloon/Makefile
deleted file mode 100644 (file)
index dabea38..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-
-CC     = gcc
-CFLAGS = -Wall -O3
-TARGET = balloon
-
-all: $(TARGET)
-
-install: all
-       mkdir -p $(prefix)/usr/bin
-       install -m0755 $(TARGET) $(prefix)/usr/bin
-
-clean:
-       $(RM) *.o $(TARGET) *~
diff --git a/tools/balloon/README b/tools/balloon/README
deleted file mode 100644 (file)
index 16c1707..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-
-The Xen balloon driver supports two operations:
- 1. Inflating - which means domain giving up pages of memory to Xen.
- 2. Deflating - which means reclaiming memory pages from Xen.
-
-Currently a domain can only claim pages from Xen up to the number of 
-previously released ones. This is to change. 
-
-Example:
-
-# balloon inflate 1000
-
-Give up 1000 pages to Xen.
-
-# balloon deflate 1000
-
-Claim 1000 pages from Xen.
diff --git a/tools/balloon/balloon.c b/tools/balloon/balloon.c
deleted file mode 100644 (file)
index e305de5..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/******************************************************************************
- * balloon.c
- *
- * Xen balloon driver userspace control tool. Used to shrink/grow domain's 
- * memory.
- *
- * Copyright (c) 2003, B Dragovic
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#define INFLATE_BALLOON      "inflate"   /* return mem to hypervisor */
-#define DEFLATE_BALLOON      "deflate"   /* claim mem from hypervisor */
-
-/* THIS IS SHARED WITH THE LINUX BALLOON DRIVER */
-#define USER_INFLATE_BALLOON  1   /* return mem to hypervisor */
-#define USER_DEFLATE_BALLOON  2   /* claim mem from hypervisor */
-typedef struct user_balloon_op {
-    unsigned int    op;
-    unsigned long   size;
-} user_balloon_op_t;
-/* END OF CODE SHARED WITH THE LINUX BALLOON DRIVER */
-
-static int open_balloon_proc()
-{
-    return open("/proc/xen/balloon", O_RDWR);
-}
-
-/* inflate balloon function signals to kernel it should relinquish memory */
-static int inflate_balloon(unsigned long num_pages)
-{
-    user_balloon_op_t bop;
-    int proc_fd;
-
-    if((proc_fd = open_balloon_proc()) <= 0){
-        printf("Error opening balloon proc file.\n");
-        return 0;
-    }
-
-    bop.op   = USER_INFLATE_BALLOON;
-    bop.size = num_pages;
-    if ( write(proc_fd, &bop, sizeof(bop)) <= 0 )
-    {
-        printf("Error writing to balloon proc file.\n");
-        return 0;
-    }
-
-    close(proc_fd);
-    return 1;
-}
-
-/* deflate balloon function signals to kernel it should claim memory */
-static int deflate_balloon(unsigned long num_pages)
-{
-    user_balloon_op_t bop;
-    int proc_fd;
-
-    if((proc_fd = open_balloon_proc()) <= 0){
-        printf("Error opening balloon proc file.\n");
-        return 0;
-    }
-
-    bop.op   = USER_DEFLATE_BALLOON;
-    bop.size = num_pages;
-    if(write(proc_fd, &bop, sizeof(bop)) <= 0){
-        printf("Error writing to balloon proc file.\n");
-        return 0;
-    }
-
-    close(proc_fd);
-    return 1;
-}
-
-int main(int argc, char *argv[])
-{
-    unsigned long num_pages;
-
-    if(argc < 2){
-        printf("Usage: balloon <inflate|deflate> <num_pages>\n");
-        return -1;
-    }
-
-    num_pages = atol(argv[2]);
-
-    if(!strcmp(argv[1], INFLATE_BALLOON)){
-        if(!inflate_balloon(num_pages)){
-            perror("Inflating balloon failed");
-            return -1;
-        }
-
-    } else if (!strcmp(argv[1], DEFLATE_BALLOON)){
-        if(!deflate_balloon(num_pages)){
-            perror("Deflating balloon failed");
-            return -1;
-        }
-
-    } else {
-        printf("Unrecognized command line argument.\n");
-        return -1;
-    }
-
-    return 0;
-}
-
-    
-
index 6ddba65621653e7afcbcddbffc79ba12b994b81a..36e9cab93f35af3aeabfe25ee6a6ade9cd276c01 100644 (file)
@@ -11,8 +11,7 @@ OBJS     = $(patsubst %.c,%.o,$(SRCS))
 
 TARGETS  = xen_cpuperf
 
-INSTALL  = $(TARGETS) xen-mkdevnodes xen_nat_enable xen-clone
-INSTALL += xen_dmesg.py xencons
+INSTALL  = $(TARGETS) xencons
 
 all: $(TARGETS)
        $(MAKE) -C miniterm
diff --git a/tools/misc/xen-mkdevnodes b/tools/misc/xen-mkdevnodes
deleted file mode 100755 (executable)
index 944ffcc..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#! /bin/bash
-
-BASE=${1:?"base directory missing (eg. /dev)"}
-
-rm -f ${BASE}/xvd[abcdefghijklmnop]*
-
-# XLVIRT is 16 devices of 15 partitions
-
-LETTERS="a b c d e f g h i j k l m n o p"
-PARTITIONS="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15"
-
-j=0
-for l in ${LETTERS}; do
-    mknod ${BASE}/xvd${l} b 125 ${j}
-    chmod 600 ${BASE}/xvd${l}
-    for i in ${PARTITIONS}; do
-        mknod ${BASE}/xvd${l}${i} b 125 $(($i+$j))
-        chmod 600 ${BASE}/xvd${l}${i}
-    done
-    j=$(($j+16))
-done
diff --git a/tools/misc/xen_dmesg.py b/tools/misc/xen_dmesg.py
deleted file mode 100755 (executable)
index 402d80d..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env python
-
-"""Reads out the contents of the console ring
-
-Usage: readconsolering.py [-c]
-The -c option causes the contents to be cleared.
-"""
-
-import sys, Xc # import the Xc Xen Control module
-
-xc = Xc.new() # get a new instance of the control interface
-
-clear_buffer = False
-
-if sys.argv[1:] != []:
-    if sys.argv[1] == "-c":
-        clear_buffer = True
-    else:
-        print >> sys.stderr, "Usage: " + sys.argv[0] + """ [-c]
-       Reads the contents of the console buffer.
-       (specifying -c will also clear current contents)"""
-
-# Get the console ring's contents as a string and print it out.
-# If argument to readconsolering is true then the buffer is cleared as well as
-# fetching the (pre-clearing) contents.
-print xc.readconsolering(clear_buffer)
diff --git a/tools/misc/xen_log.c b/tools/misc/xen_log.c
deleted file mode 100644 (file)
index 29f7d4c..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-
-#include <netinet/in.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <syslog.h>
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <string.h>
-
-#include "dom0_defs.h"
-#include "mem_defs.h"
-
-#define SILENT_ERRORS_FROM_XEN
-#define SYSLOG 1
-#define SYSLOGTO LOG_LOCAL5
-
-int logoutput;
-
-void stripit(char *str)
-{
-    int i;
-    for ( i = 0; str[i]; i++ )
-        if ( (str[i] == '\n') || (str[i] == '\r') ) 
-            str[i] = '\0';
-}
-
-void errexit(char *str)
-{
-    if ( logoutput == SYSLOG )
-    {
-        stripit(str);
-        syslog(LOG_ERR, "%s failed: %d (%m)", str, errno);
-    } 
-    else 
-    {
-        printf("%s", str);
-    }
-    exit(1);
-}
-
-void log(char *str)
-{
-    if ( logoutput == SYSLOG )
-    {
-        stripit(str);
-        syslog(LOG_INFO, "%s", str);
-    } 
-    else 
-    {
-        printf("%s", str);
-    }
-}
-
-void process(void)
-{
-    dom0_op_t op;
-    unsigned char buf[208], obuf[224];
-    struct sockaddr_in addr, from;
-    int fromlen = sizeof(from);
-    int len, fd = socket(PF_INET, SOCK_DGRAM, 0);
-    unsigned short int lastport = 0, curport = 0;
-    
-    if ( fd < 0 )
-        errexit("could not open datagram socket");
-
-    memset(&addr, 0, sizeof(addr));
-    addr.sin_addr.s_addr = htonl(0xa9fe0100); /* 169.254.1.0 */
-    addr.sin_port = htons(666);
-    addr.sin_family = AF_INET;
-
-    if ( bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0 )
-        errexit("could not bind to local address and port");
-
-    op.cmd = DOM0_GETDOMAININFO;
-
-    while ( (len = recvfrom(fd, buf, sizeof(buf), 0,
-                            (struct sockaddr *)&from, &fromlen)) >= 0 )
-    {
-        curport = ntohs(from.sin_port);
-        if ( lastport != curport )
-        {
-            op.u.getdomaininfo.domain = (int)curport;
-            if ( do_dom0_op(&op) < 0 )
-                log("Error resolving domain name\n");
-            else
-                lastport = curport;
-        }
-
-        sprintf(obuf, "[%s] %s", op.u.getdomaininfo.name, buf);
-        log(obuf);
-
-        fromlen = sizeof(from);
-    }
-}
-
-void closeall(int fd)
-{
-    int fdlimit = sysconf(_SC_OPEN_MAX);
-
-    while (fd < fdlimit)
-        close(fd++);
-}
-
-int daemon(int nochdir, int noclose)
-{
-    switch (fork())
-    {
-    case 0:  break;
-    case -1: return -1;
-    default: _exit(0);
-    }
-
-    if (setsid() < 0)
-        return -1;
-
-    switch (fork())
-    {
-    case 0:  break;
-    case -1: return -1;
-    default: _exit(0);
-    }
-
-    if (!nochdir)
-        chdir("/");
-
-    if (!noclose)
-    {
-        closeall(0);
-        open("/dev/null",O_RDWR);
-        dup(0); dup(0);
-    }
-
-    return 0;
-}
-
-int main(int argc, char **argv)
-{
-    int c;
-
-    logoutput = 0;
-    opterr = 0;
-
-    while ( (c = getopt (argc, argv, "dh")) != -1 )
-    {
-        switch(c)
-        {
-        case 'd':
-            logoutput = SYSLOG;
-            if (daemon(0,0) < 0)
-            {
-                errno = 2;
-                errexit("daemon");
-            } else {
-                openlog("xen_log", LOG_PID, SYSLOGTO);
-            }
-            break;
-        case 'h':
-            printf("Usage: xen_log [options]\n");
-            printf("Capture and display output of xen domains.\n\n");
-            printf("  -d       Daemonize and send output to syslog.\n");
-            exit(0);
-            break;
-        }
-    }
-
-    process();
-
-    return 0;
-}
-
diff --git a/tools/misc/xen_nat_enable b/tools/misc/xen_nat_enable
deleted file mode 100755 (executable)
index ea6b107..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-
-run_iptables() {
-    if ! iptables $@ ; then
-       echo "iptables returned error; have you built netfilter?"; exit 1
-    fi
-}
-
-ifconfig eth0 up
-ifconfig eth0:xen 169.254.1.0 up
-
-run_iptables -t filter -F
-run_iptables -t nat -F
-run_iptables -t filter -X
-run_iptables -t nat -X
-run_iptables -t filter -P FORWARD DROP
-run_iptables -t filter -A FORWARD -i eth0 -o eth0 -s 169.254.0.0/16 -j ACCEPT
-run_iptables -t filter -A FORWARD -i eth0 -o eth0 -d 169.254.0.0/16 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
-run_iptables -t nat -A POSTROUTING -o eth0 -s 169.254.1.0 -j RETURN
-run_iptables -t nat -A POSTROUTING -o eth0 -s 169.254.0.0/16 -j MASQUERADE
-echo 1 > /proc/sys/net/ipv4/ip_forward
-
-#set up some port redirects for ssh
-run_iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2201 -j DNAT --to 169.254.1.1:22
-run_iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2202 -j DNAT --to 169.254.1.2:22
-run_iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2203 -j DNAT --to 169.254.1.3:22
-run_iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2204 -j DNAT --to 169.254.1.4:22
-run_iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2205 -j DNAT --to 169.254.1.5:22
-run_iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2206 -j DNAT --to 169.254.1.6:22
-run_iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2207 -j DNAT --to 169.254.1.7:22
-run_iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2208 -j DNAT --to 169.254.1.8:22
-run_iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2209 -j DNAT --to 169.254.1.9:22
-run_iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2210 -j DNAT --to 169.254.1.10:22
-
-
diff --git a/tools/misc/xen_nat_enable.README b/tools/misc/xen_nat_enable.README
deleted file mode 100644 (file)
index 0c6dd1c..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-To use NAT in domain 0 to give access for other domains:
-1) Make sure domain 0's kernel contains at least the following options:
-   (other domains don't need this)
-
-CONFIG_NETFILTER=y
-CONFIG_IP_NF_CONNTRACK=y
-CONFIG_IP_NF_FTP=y
-CONFIG_IP_NF_IPTABLES=y
-CONFIG_IP_NF_MATCH_STATE=y
-CONFIG_IP_NF_FILTER=y
-CONFIG_IP_NF_NAT=y
-CONFIG_IP_NF_NAT_NEEDED=y
-CONFIG_IP_NF_TARGET_MASQUERADE=y
-CONFIG_IP_NF_NAT_FTP=y
-
-2) Run the enable_nat script on domain 0 startup. This will bind
-   169.254.1.0 to domain 0 and set up iptables for NAT. Make sure
-   that the real IP address for eth0 has been set before running the
-   script.
-3) Give the other domains IP addresses in 169.254.0.0/16 and a default
-   gateway of 169.254.1.0.
-4) It should now work. Domains 1 and higher should be able to make
-   outgoing connections through NAT. FTP active or passive should both
-   work thanks to FTP connection tracking
diff --git a/tools/nsplitd/Makefile b/tools/nsplitd/Makefile
deleted file mode 100644 (file)
index c5c4c9e..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-
-CC     = gcc
-CFLAGS = -Wall -O3
-CFILES = $(wildcard *.c)
-
-HDRS     = $(wildcard *.h)
-OBJS     = $(patsubst %.c,%.o,$(wildcard *.c))
-
-TARGET   = nsplitd
-
-all: $(TARGET)
-
-install: all
-
-clean:
-       $(RM) *.o $(TARGET) *~
-
-$(TARGET): $(OBJS)
-       $(CC) $(CFLAGS) -o $@ $^
-
-%.o: %.c $(HDRS) Makefile
-       $(CC) $(CFLAGS) -c -o $@ $<
diff --git a/tools/nsplitd/nsplitd.c b/tools/nsplitd/nsplitd.c
deleted file mode 100644 (file)
index 48fbd65..0000000
+++ /dev/null
@@ -1,686 +0,0 @@
-/*
- *     nsplitd.c
- *     ---------
- *
- * $Id: nsplitd.c,v 2.6 1998/09/17 14:28:37 sde1000 Exp $
- *
- * Copyright (c) 1995, University of Cambridge Computer Laboratory,
- * Copyright (c) 1995, Richard Black, All Rights Reserved.
- *
- *
- * A complete re-implementation of DME's nsplitd for use from inetd
- *
- */
-
-/* The basic stream comes in (via inetd) and we then conenct to
- * somewhere else providing a loop-through service, except we offer
- * two other ports for connection - one of which gets a second channel
- * using the top bit to distinguish, and the other is a master control
- * port (normally used for gdb) which gets complete exclusive access
- * for its duration.
- *
- * Originally designed for multiplexing a xwcons/telnet with a gdb
- * post-mortem debugging session.
- *
- * Here is a picture:
- *
- *                                         port0 (from inetd)
- *      8-bit connection                  /
- *        made by us      <----> nsplitd <-----gdbport (default port0+2)
- *     to host:port/tcp                  |\
- *                                       | port1 (default port0+1)
- *                                         \
- *                                          control (default port0+3)
- *
- * If port1 is explicitly disabled (through a command-line option) then
- * port0 becomes 8-bit clean.
- */
-
-/*
- * N.B.: We do NOT support 8 bit stdin/stdout usage on a
- * /dev/... because to do that right involves much messing with ioctl
- * and TIOC... etc.  If you want to do that sort of thing then the
- * right way to do it is to chain this onto wconsd (which does know
- * about and understand all the ioctl and TIOC grief).
- */
-
-#include <sys/types.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <errno.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <netdb.h>
-#include <string.h>
-
-#include <sys/time.h>
-#include <sys/signal.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-#include <sys/ioctl.h>
-#include <syslog.h>
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef LOG_DAEMON
-#define LOG_DAEMON 0
-#endif
-
-#define DB(x)  /* ((x), fflush(stderr)) */
-
-extern char *optarg;
-
-extern int optind, opterr, optopt;
-
-static char *prog_name;
-
-static void usage(void)
-{
-    fprintf(stderr, "This program (%s) should be run via inetd (tcp)\n\n",
-           prog_name);
-    fprintf(stderr, "usage: %s [-h<highport>][-g<gdbport>]"
-           "[-c<ctlport>][-8] host:service\n",
-           prog_name);
-    exit(1);
-}
-
-static void fault(char *format, ...)
-{
-    va_list            ap;
-    char               logbuf[1024];
-
-    va_start(ap, format);
-    fprintf(stderr, "%s: ", prog_name);
-    vfprintf(stderr, format, ap);
-    fflush(stderr);
-    va_end(ap);
-    
-    /* XXX This is a bit dubious, but there is no vsyslog */
-    va_start(ap, format);
-    vsprintf(logbuf, format, ap);
-    syslog(LOG_ERR, logbuf);
-    va_end(ap);
-    exit(1);
-}
-
-static int getservice(char *name, unsigned short *port)
-{
-    struct servent             *se;
-
-    if (!name) return -1;
-
-    if (isdigit(name[0]))
-       *port = atoi(name);
-    else
-    {
-       if (!(se = getservbyname(name, "tcp")))
-           return -1;
-       *port = ntohs(se->s_port);
-    }
-    return 0;
-}
-
-/* 
- *  connect_host: connect to ("name", "port")
- */
-static int connect_host (char *name, unsigned int port)
-{
-    int                        fd;
-    struct hostent     *hostent;
-    struct sockaddr_in sin;
-    int                        on;
-    
-    if ((fd = socket (AF_INET, SOCK_STREAM, 0)) < 0)
-       fault("socket");
-    
-    if (!(hostent = gethostbyname(name)))
-       fault("gethostbyname: %s: %s\n", name, strerror(errno));
-    
-    memset(&sin, 0, sizeof(sin));
-    sin.sin_family = AF_INET;
-    sin.sin_port   = htons (port);
-    memcpy(&sin.sin_addr.s_addr, hostent->h_addr, sizeof(struct in_addr));
-    
-    if (connect(fd, (struct sockaddr *) &sin, sizeof (sin)) < 0)
-       fault("connect: %s:%u: %s\n", name, port, strerror(errno));
-    
-    on = 1;
-    if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof (on)) < 0)
-       syslog(LOG_WARNING, "setsockopt (TCP_NODELAY): %m");
-
-    on = 1;
-    if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof (on)) < 0)
-       syslog(LOG_WARNING, "setsockopt (SO_KEEPALIVE): %m");
-
-    return fd;
-}
-
-/*
- * open a tcp socket and start listening for connections on it
- */
-static int startlistening(unsigned short port)
-{
-    int                        fd, on;
-    struct sockaddr_in sin;
-
-    if ((fd = socket (AF_INET, SOCK_STREAM, 0)) < 0)
-       fault("socket");
-    
-    on = 1;
-    if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0)
-      syslog(LOG_WARNING, "setsockopt (SO_REUSEADDR): %m");
-
-    memset(&sin, 0, sizeof(sin));
-    sin.sin_family      = AF_INET;
-    sin.sin_port        = htons (port);
-    sin.sin_addr.s_addr = INADDR_ANY;
-    if (bind(fd, &sin, sizeof(sin)) < 0)
-       fault("bind: %u: %s\n", port, strerror(errno));
-    
-    if (listen(fd, 1) < 0)
-       fault("listen: %s\n", strerror(errno));
-    
-    return fd;
-}
-
-static void noblock(int fd)
-{
-    int on=1;
-    
-    if (ioctl(fd, FIONBIO, &on) < 0)
-       fault("ioctl: FIONBIO: %s\n", strerror(errno));
-}
-
-
-/* You might not believe this, but fd_sets don't have to be a 32-bit
- * integer.  In particular, in glibc2 it is an array of unsigned
- * longs.  Hence, this hacked up FD_SET_rjb() that works out if it
- * would have been a nop. */
-#define FD_SET_rjb(fd, setp) \
-do {                                           \
-    if ((fd) != 32)                            \
-       FD_SET((fd), (setp));                   \
-} while(0)
-
-#define FD_ISSET_rjb(fd, setp) (((fd) != 32)? FD_ISSET((fd), (setp)) : 0)
-
-#define MAXSIZE        256
-
-/* -----------------------------------------------------------------
- * The main bit of the algorithm. Note we use 32 to mean not connected
- * because this gives us 1<<32 == 0. We could have done this one
- * character at a time, but that would have been very inefficient and
- * not the unix way.  */
-static int debug;
-
-static void doit(int actl, int acto, int lish, int lisg, int lisc)
-{
-    int                acth, actg, actc;
-    int                gdbmode = FALSE;
-    char       gibuf[MAXSIZE], oibuf[MAXSIZE];
-    char       libuf[MAXSIZE], lobuf[MAXSIZE];
-    char       hibuf[MAXSIZE], hobuf[MAXSIZE];
-    char       ctlbuf[MAXSIZE];
-    fd_set     rdfs, wrfs, exfs;
-    int                gicc, oicc, licc, locc, hicc, hocc, ctlcc;
-    char       *giptr, *oiptr, *liptr, *loptr, *hiptr, *hoptr;
-    int                rc, fromlen;
-    struct sockaddr_in         from;
-    
-    gicc = oicc = licc = locc = hicc = hocc = ctlcc = 0;
-    acth = actg = actc = 32;                   /* XXX yummy */
-
-    noblock(actl);
-    noblock(acto);
-
-    for(;;)
-    {
-       FD_ZERO(&rdfs);
-       FD_ZERO(&wrfs);
-       FD_ZERO(&exfs);
-
-       /* always take input from the control port (if it's connected) */
-       FD_SET_rjb(actc, &rdfs);
-
-       if (gdbmode)
-       {
-           if (oicc)
-               FD_SET_rjb(actg, &wrfs);
-           else
-               FD_SET_rjb(acto, &rdfs);
-           
-           if (gicc)
-               FD_SET_rjb(acto, &wrfs);
-           else
-               FD_SET_rjb(actg, &rdfs);
-       }
-       else
-       {
-           /* There is no such thing as oibuf because its been split into
-            * lobuf and hobuf
-            */
-           if (locc || hocc)
-           {
-               if (locc)
-                   FD_SET_rjb(actl, &wrfs);
-               if (hocc)
-                   FD_SET_rjb(acth, &wrfs);
-           }
-           else
-               FD_SET_rjb(acto, &rdfs);
-           
-           if (licc)
-               FD_SET_rjb(acto, &wrfs);
-           else
-               FD_SET_rjb(actl, &rdfs);
-           
-           if (hicc)
-               FD_SET_rjb(acto, &wrfs);
-           else
-               FD_SET_rjb(acth, &rdfs);
-       }
-       
-       if (acth == 32 && lish>=0)      FD_SET_rjb(lish, &rdfs);
-       if (actg == 32)                 FD_SET_rjb(lisg, &rdfs);
-       if (actc == 32)                 FD_SET_rjb(lisc, &rdfs);
-
-       /* now make exfs the union of the read and write fd sets, plus
-        * "actl" */
-       {
-           int i;
-           exfs = rdfs;
-           for(i=0; i<32; i++)  /* XXX we only copy fd numbers up to 31 */
-               if (FD_ISSET(i, &wrfs))
-                   FD_SET_rjb(i, &exfs);
-           FD_SET_rjb(actl, &exfs);
-       }
-
-       /* XXX AND: can't print something of type fd_set as %x - it
-         * might be an array */
-       DB(fprintf(stderr, "%s: before select: %08x %08x %08x\n",
-                  prog_name, rdfs, wrfs, exfs));
-       
-       if (select(32, &rdfs, &wrfs, &exfs, NULL) < 0)
-           fault("select: %s\n", strerror(errno));
-       
-       DB(fprintf(stderr, "%s: after  select: %08x %08x %08x\n",
-                  prog_name, rdfs, wrfs, exfs));
-       
-       /* XXX it appears that a non-blocking socket may not show up
-        * correctly in exfs but instead goes readable with no data in
-        * it. Thus we check for zero and goto the appropriate close
-        * method.  */
-
-       /* Deal with exceptions */
-       if (FD_ISSET_rjb(actg, &exfs))
-       {
-       exfs_actg:
-           close(actg);
-           gdbmode = FALSE;
-           oicc = 0;
-           oiptr = oibuf;
-           actg = 32;
-           continue;           /* because assumptions changed */
-       }
-       if (FD_ISSET_rjb(acth, &exfs))
-       {
-       exfs_acth:
-           close(acth);
-           hicc = hocc = 0;
-           hiptr = hibuf;
-           hoptr = hibuf;
-           acth = 32;
-           continue;           /* because assumptions changed */
-       }
-       if (FD_ISSET_rjb(actl, &exfs) ||
-           FD_ISSET_rjb(acto, &exfs))
-       {
-       exfs_actl:
-       exfs_acto:
-           /* Thats all folks ... */
-           break;
-       }
-       if (FD_ISSET_rjb(actc, &exfs))
-       {
-       exfs_ctl:
-           close(actc);
-           actc = 32;
-           ctlcc = 0;
-           continue;
-       }
-
-       /* Deal with reading */
-       if (FD_ISSET_rjb(acto, &rdfs))
-       {
-           if ((oicc = read(acto, oiptr = oibuf, MAXSIZE)) < 0)
-               fault("read acto: %d: %s\n", oicc, strerror(errno));
-           if (!oicc) goto exfs_acto;
-           
-           if (!gdbmode)
-           {
-               int t;
-
-               assert((locc == 0) && (hocc == 0));
-               loptr = lobuf;
-               hoptr = hobuf;
-               
-               if (lish>=0) {
-                   for(t=0; t<oicc; t++)
-                       if (oibuf[t] & 0x80)
-                           hobuf[hocc++] = oibuf[t] & 0x7f;
-                       else
-                           lobuf[locc++] = oibuf[t];
-               } else {
-                   for (t=0; t<oicc; t++)
-                       lobuf[locc++] = oibuf[t];
-               }
-               /* If no high connection scratch that */
-               if (acth == 32)
-                   hocc=0;
-           }
-       }
-       if (FD_ISSET_rjb(actl, &rdfs))
-       {
-           if ((licc = read(actl, liptr = libuf, MAXSIZE)) < 0)
-               fault("read actl: %d: %s\n", licc, strerror(errno));
-           if (!licc) goto exfs_actl;
-       }
-       if (FD_ISSET_rjb(acth, &rdfs))
-       {
-           int t;
-           
-           if ((hicc = read(acth, hiptr = hibuf, MAXSIZE)) < 0)
-               fault("read acth: %d: %s\n", hicc, strerror(errno));
-           if (!hicc) goto exfs_acth;
-           for(t=0; t<hicc; t++)
-               hibuf[t] |= 0x80;
-       }
-       if (FD_ISSET_rjb(actg, &rdfs))
-       {
-           if ((gicc = read(actg, giptr = gibuf, MAXSIZE)) < 0)
-               fault("read actg: %d: %s\n", gicc, strerror(errno));
-           if (debug) write(1, giptr, gicc);           /* XXX */
-           if (!gicc) goto exfs_actg;
-       }
-       if (FD_ISSET_rjb(actc, &rdfs))
-       {
-           if ((ctlcc = read(actc, ctlbuf, MAXSIZE)) < 0)
-               fault("read actc: %d: %s\n", ctlcc, strerror(errno));
-           if (debug) write(1, ctlbuf, gicc);
-           if (!ctlcc) goto exfs_ctl;
-           if (ctlbuf[0] == 'r') /* reset command */
-           {
-               syslog(LOG_INFO, "reset command read, exiting");
-               if (debug) write(1, "reseting\n", sizeof("reseting\n"));
-               break;
-           }
-       }
-       
-       /* Deal with writing */
-       if (FD_ISSET_rjb(actg, &wrfs))
-       {
-           /* We must be in gdb mode so send oi buffer data */
-           assert(gdbmode);
-           if (debug) write(2, oiptr, oicc);           /* XXX */
-           if ((rc = write(actg, oiptr, oicc)) <= 0)
-               fault("write actg: %d: %s\n", rc, strerror(errno));
-           oiptr += rc;
-           oicc  -= rc;
-       }
-       if (FD_ISSET_rjb(actl, &wrfs))
-       {
-           if ((rc = write(actl, loptr, locc)) <= 0)
-               fault("write actl: %d: %s\n", rc, strerror(errno));
-           loptr += rc;
-           locc  -= rc;
-       }
-       if (FD_ISSET_rjb(acth, &wrfs))
-       {
-           if ((rc = write(acth, hoptr, hocc)) <= 0)
-               fault("write acth: %d: %s\n", rc, strerror(errno));
-           hoptr += rc;
-           hocc  -= rc;
-       }
-       if (FD_ISSET_rjb(acto, &wrfs))
-       {
-           /* If in gdb mode send gdb input, otherwise send low data
-              preferentially */
-           if (gdbmode)
-           {
-               assert(gicc);
-               if ((rc = write(acto, giptr, gicc)) <= 0)
-                   fault("write acto: %d: %s\n", rc, strerror(errno));
-               giptr += rc;
-               gicc  -= rc;
-           }
-           else
-           {
-               if (licc)
-               {
-                   if ((rc = write(acto, liptr, licc)) <= 0)
-                       fault("write acto: %d: %s\n", rc, strerror(errno));
-                   liptr += rc;
-                   licc  -= rc;
-               }
-               else
-               {
-                   assert(hicc);
-                   if ((rc = write(acto, hiptr, hicc)) <= 0)
-                       fault("write acto: %d: %s\n", rc, strerror(errno));
-                   hiptr += rc;
-                   hicc  -= rc;
-               }
-           }
-       }
-       
-       /* Deals with new connections */
-       if ((acth == 32) && lish>=0 && (FD_ISSET_rjb(lish, &rdfs)))
-       {
-           fromlen = sizeof(from);
-           if ((acth = accept(lish, &from, &fromlen)) < 0)
-           {
-               syslog(LOG_WARNING, "accept: %m");
-               acth = 32;
-           }
-           else
-           {
-               noblock(acth);
-               hicc = hocc = 0;
-               syslog(LOG_INFO, "highbit client peer is %s:%u\n",
-                      inet_ntoa(from.sin_addr), ntohs(from.sin_port));
-           }
-       }
-       
-       if ((actg == 32) && (FD_ISSET_rjb(lisg, &rdfs)))
-       {
-           fromlen = sizeof(from);
-           if ((actg = accept(lisg, &from, &fromlen)) < 0)
-           {
-               syslog(LOG_WARNING, "accept: %m");
-               actg = 32;
-           }
-           else
-           {
-               noblock(actg);
-               gicc = 0;
-               gdbmode = TRUE;
-               syslog(LOG_INFO, "gdb client peer is %s:%u\n",
-                      inet_ntoa(from.sin_addr), ntohs(from.sin_port));
-           }
-       }
-
-       if ((actc == 32) && (FD_ISSET_rjb(lisc, &rdfs)))
-       {
-           fromlen = sizeof(from);
-           if ((actc = accept(lisc, &from, &fromlen)) < 0)
-           {
-               syslog(LOG_WARNING, "accept (ctl): %m");
-               actc = 32;
-           }
-           else
-           {
-               noblock(actc);
-               syslog(LOG_INFO, "ctl client peer is %s:%u\n",
-                      inet_ntoa(from.sin_addr), ntohs(from.sin_port));
-           }
-       }
-           
-       /* Back to top of loop */
-    }
-    
-    /* We are bailing because one of the primary connections has gone
-     * away. We close these all explicitly here because that way the
-     * timeout on reusing the port numbers is smnaller. */
-    
-    close(acth);
-    close(actg);
-    /* XXX AND: why are we closing all these "character counts" ?? */
-    close(gicc);
-    close(oicc);
-    close(licc);
-    close(locc);
-    close(hicc);
-    close(hocc);
-}
-
-/*
- * ------------------------------------------------------------
- */
-int main(int argc, char **argv)
-{
-    /* In general, suffix "l" is low channel, "h" is high channel, "g"
-     * is gdb channel, "c" is control channel and "o" is output channel.
-     */
-    struct sockaddr_in         from;
-    int                                infd = 0, outfd;
-    unsigned short             portl, porth, portg, portc, porto;
-    int                                on = 1, c;
-    char                       *outname, *outservice;
-    int                                fromlen;
-    int                                lish, lisg, lisc;
-#if 0
-    FILE                       *newerr;
-#endif /* 0 */
-    
-    prog_name = argv[0];
-
-    if (isatty(infd))
-       usage();
-
-    /* Here, then not just a simple idiot. */
-
-    signal(SIGPIPE, SIG_IGN);
-
-    openlog(prog_name, LOG_PID, LOG_DAEMON);
-
-    fromlen = sizeof(from);
-    if (getsockname(infd, &from, &fromlen) < 0)
-       fault("getsockname: %s", strerror(errno));
-    if ((fromlen != sizeof(from)) || (from.sin_family != AF_INET))
-       fault("not an inet socket (family=%d)\n", from.sin_family);
-    
-    portl = ntohs(from.sin_port);
-    porth = portl+1;
-    portg = porth+1;
-    portc = portg+1;
-
-    fromlen = sizeof(from);
-    if (getpeername(infd, &from, &fromlen) < 0)
-       fault("getpeername: %s", strerror(errno));
-    if ((fromlen != sizeof(from)) || (from.sin_family != AF_INET))
-       fault("not an inet socket (family=%d)\n", from.sin_family);
-
-    syslog(LOG_INFO, "on port %u peer is %s:%u\n", portl,
-          inet_ntoa(from.sin_addr), ntohs(from.sin_port));
-    
-    if (setsockopt(infd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof (on)) < 0)
-       syslog(LOG_WARNING, "setsockopt (SO_KEEPALIVE): %m");
-
-    /* from here on, we map stderr to output on the connection so we can
-     * report errors to the remote user.
-     */
-#if 0
-    if (!(newerr = fdopen(infd, "w")))
-       syslog(LOG_WARNING, "fdopen: %m");
-    else
-       *stderr = *newerr;
-#endif
-       
-    while((c = getopt(argc, argv, "d8h:g:c:")) != EOF)
-    {
-       switch(c)
-       {
-       case 'd':
-           debug++;
-           break;
-           
-       case 'h':
-           /* high bit port */
-           if (getservice(optarg, &porth) < 0)
-               fault("getservice failed (high port '%s')\n", optarg);
-           break;
-           
-       case 'g':
-           /* gdb port */
-           if (getservice(optarg, &portg) < 0)
-               fault("getservice failed (gdb port '%s')\n", optarg);
-           break;
-
-       case 'c':
-           /* control port */
-           if (getservice(optarg, &portc) < 0)
-               fault("getservice failed (control port '%s')\n", optarg);
-           break;
-
-       case '8':
-           /* 8-bit clean; no high port */
-           porth=0;
-           break;
-
-       default:
-           fault("bad argument list!\n");
-       }
-    }
-    
-    if (argc != optind + 1)
-       fault("unparsed arguments (%d!=%d)\n", argc, optind+1);
-
-    outname = argv[optind];
-    if (!(outservice = strchr(outname, ':')))
-       fault("output arg '%s' doesn't contain ':'\n", outname);
-    *outservice++ = 0;
-    if (getservice(outservice, &porto) < 0)
-       fault("getservice failed (output port '%s')\n", outservice);
-    
-    /* Time to start the sockets */
-
-    if (porth) {
-       lish  = startlistening(porth);
-    } else {
-       lish  = -1;
-    }
-    lisg  = startlistening(portg);
-    lisc  = startlistening(portc);
-    
-    outfd = connect_host(outname, porto);
-    
-    doit(infd, outfd, lish, lisg, lisc);
-
-    syslog(LOG_INFO, "terminating normally\n");
-
-    fclose(stderr);
-
-    closelog();
-    exit(0); 
-}
-
-/* End $Id: nsplitd.c,v 2.6 1998/09/17 14:28:37 sde1000 Exp $ */